import Vue from 'vue'
import router from 'vue-router'
// 公共部分
const NotFound = () =>
    import ('../components/NotFound.vue')
    // 管理员界面
const AdminLogin = () =>
    import ('../views/admin/Login.vue')
const AdminIndex = () =>
    import ('../views/admin/Index.vue')
const AdminMain = () =>
    import ('../views/admin/initial/Main.vue')
const AdminPersonal = () =>
    import ('../views/admin/initial/Personal.vue')
const AdminArticle = () =>
    import ('../views/admin/operation/Article.vue')
const AdminImage = () =>
    import ('../views/admin/operation/Image.vue')
const AdminMessage = () =>
    import ('../views/admin/user/Message.vue')
const AdminHomeIndex = () =>
    import ('../views/admin/operation/HomeIndex.vue')
const AdminActions = () =>
    import ('../views/admin/user/Actions.vue')
const AdminLogout = () =>
    import ('../views/admin/logout.vue')
const AdminNote = () =>
    import ('../views/admin/operation/Note.vue')
    // 用户界面
const Index = () =>
    import ('../views/blog/Index.vue')
const BlogIndex = () =>
    import ('../views/blog/TopNavigation/BlogIndex.vue')
const BlogCasualRecord = () =>
    import ('../views/blog/TopNavigation/CasualRecord.vue')
const BlogCasualPhoto = () =>
    import ('../views/blog/TopNavigation/CasualPhoto.vue')
const BlogNote = () =>
    import ('../views/blog/TopNavigation/Note.vue')

Vue.use(router)

export default new router({

    routes: [

        // 公共
        {
            // 404页
            path: '*',
            mate: "错误",
            name: 'NotFound',
            component: NotFound
        },
        // 重定向页
        {
            path: '',
            redirect: '/blog/index'
        },
        // 重定向页
        {
            path: '/admin',
            redirect: '/admin/login'
        },
        {
            path: '/admin/logout',
            redirect: '/admin/login'

        },

        // 管理员

        {
            // 管理员登录页
            path: '/admin/login',
            name: 'AdminLogin',
            mate: "管理员登陆",
            component: AdminLogin
        },
        {
            // 管理员注销
            path: '/admin/logout',
            name: 'AdminLogout',
            mate: "管理员注销",
            component: AdminLogout
        },
        {
            // 管理员首页
            path: '/admin/index',
            name: 'AdminIndex',
            mate: "管理员首页",
            component: AdminIndex,
            children: [

                {
                    // 主要界面
                    path: '/admin/initial/main',
                    name: 'AdminMain',
                    mate: "内容",
                    component: AdminMain
                },
                {
                    // 个人中心
                    path: '/admin/initial/personal',
                    name: 'AdminPersonal',
                    mate: "个人信息",
                    component: AdminPersonal
                },
                {
                    // 首页界面
                    path: '/admin/operation/homeindex',
                    name: 'AdminHomeIndex',
                    mate: "首页管理",
                    component: AdminHomeIndex
                },
                {
                    // 笔记界面
                    path: '/admin/operation/note',
                    name: 'AdminNote',
                    mate: "笔记界面",
                    component: AdminNote
                },
                {
                    // 文章管理
                    path: '/admin/operation/article',
                    name: 'AdminArticle',
                    mate: "文章管理",
                    component: AdminArticle
                },
                {
                    // 图片管理
                    path: '/admin/operation/image',
                    name: 'AdminImage',
                    mate: "图片管理",
                    component: AdminImage
                },
                {
                    // 用户信息
                    path: '/admin/user/message',
                    name: 'AdminMessage',
                    mate: "用户信息",
                    component: AdminMessage
                },
                {
                    // 用户管理
                    path: '/admin/user/actions',
                    name: 'AdminActions',
                    mate: "用户管理",
                    component: AdminActions
                },

            ]
        },


        // 用户

        {
            // 导航首页
            path: '/blog/index',
            name: 'Index',
            component: Index,
            // beforeEnter: (to, from, next) => {
            //     if (to.path == '/')
            //         next('/blog/index')
            //     else
            //         next()
            // },
            children: [{
                    // 主页界面
                    path: '/blog/index/TopNavigation/BlogIndex',
                    name: 'BlogIndex',
                    mate: "主页",
                    component: BlogIndex,
                },
                {
                    // 随记界面
                    path: '/blog/index/TopNavigation/BlogCasualRecord',
                    name: 'BlogCasualRecord',
                    mate: "随记",
                    component: BlogCasualRecord
                },
                {
                    // 随拍界面
                    path: '/blog/index/TopNavigation/BlogCasualPhoto',
                    name: 'BlogCasualPhoto',
                    mate: "随拍",
                    component: BlogCasualPhoto
                },
                {
                    // 笔记界面
                    path: '/blog/index/TopNavigation/BlogNote',
                    name: 'BlogNote',
                    mate: "笔记",
                    component: BlogNote
                },

            ]
        }

    ]

})